//
//  UserRelationCell.m
//  collection
//
//  Created by 张靖 on 4/15/12.
//  Copyright (c) 2012 Tsinghua University. All rights reserved.
//

#import "UserRelationCell.h"

@interface UserRelationCell()

- (IBAction)onClickActionButton:(id)sender;

@end

@implementation UserRelationCell

@synthesize avatarImageView = _avatarImageView;
@synthesize nicknameLabel   = _nicknameLabel;
@synthesize signatureLabel  = _signatureLabel;
@synthesize actionButton    = _actionButton;

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        UIView* bgView = [[UIView alloc] initWithFrame:self.frame];
        bgView.backgroundColor = [UIColor colorWithRed:229.0 / 255.0 green:229.0 / 255.0 blue:229.0 / 255.0 alpha:1];
        self.selectedBackgroundView = bgView;
        [bgView release];
    }
    
    return self;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)dealloc {
    
    self.avatarImageView = nil;
    self.nicknameLabel = nil;
    self.signatureLabel = nil;
    self.actionButton = nil;
    
    [super dealloc];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setActionButtonTitle:(NSString *)text {
    
    [self.actionButton setTitle:text forState:UIControlStateNormal];
    [self.actionButton setTitle:text forState:UIControlStateSelected];
}

- (IBAction)onClickActionButton:(id)sender {
    
    NSString* text = [self.actionButton titleForState:UIControlStateNormal];
    if ([text isEqualToString:@"关注"]) {
        [self setActionButtonTitle:@"取消关注"];
    }
    else {
        [self setActionButtonTitle:@"关注"];
    }
}

@end
